/*
 * create by lixy 20150323
 * Just for DMap(tuteng) Project
 * copyright@ 2015
 */
"use strict";

var $GLOBAL_USER = 'developer';
var app = angular.module('manager.admin',
    ['ngRoute', 'ngSanitize',
        'ui.router',
        'angular-timeline',
        'angular-scroll-animate']);

app.config(function($sceDelegateProvider) {
    $sceDelegateProvider.resourceUrlWhitelist([
        'self',
        'http://grafana-zp.58corp.com/**',
        'http://yunchuang.58corp.com/**',
        '**',
        '*']);
});
app.config(['$routeProvider', function ($routeProvider) {
    $routeProvider
        //ads
        .when('/admin', {
            templateUrl: './admin.html',
            controller: 'adminController'
        })
        // help
        .when('/star/help/issue_list', {
            templateUrl: './pages/help/issue_list.html',
            controller: 'issueListController'
        })
        .when('/star/help/issue_add/:id', {
            templateUrl: './pages/help/issue_add.html',
            controller: 'issueAddController'
        })
        .when('/star/help/helpdoc_list', {
            templateUrl: './pages/help/helpdoc_list.html',
            controller: 'helpdocListController'
        })
        .when('/star/help/helpdoc_add/:id', {
            templateUrl: './pages/help/helpdoc_add.html',
            controller: 'helpdocAddController'
        })

        // syslog
        .when('/star/syslog/syslog_list', {
            templateUrl: './pages/syslog/syslog_list.html',
            controller: 'syslogListController'
        })
        .when('/star/syslog/syslog_summary_list', {
            templateUrl: './pages/syslog/syslog_summary_list.html',
            controller: 'syslogSummaryListController'
        })
        .when('/star/syslog/syslog_user_list', {
            templateUrl: './pages/syslog/syslog_user_list.html',
            controller: 'syslogUserListController'
        })
        .when('/star/syslog/syslog_log_list', {
            templateUrl: './pages/syslog/syslog_log_list.html',
            controller: 'syslogLogListController'
        })

        // user
        .when('/star/user/user_list', {
            templateUrl: './pages/user/user_list.html',
            controller: 'userListController'
        })
        .when('/star/user/user_add/:id', {
            templateUrl: './pages/user/user_add.html',
            controller: 'userAddController'
        })
        .when('/star/user/user_group', {
            templateUrl: './pages/user/user_group.html',
            controller: 'userGroupController'
        })
        .when('/star/user/user_group_add/:id', {
            templateUrl: './pages/user/user_group_add.html',
            controller: 'userGroupAddController'
        })
        .when('/star/user/user_group_role/:userGroupId', {
            templateUrl: './pages/user/user_group_role.html',
            controller: 'userGroupRoleController'
        })
        .when('/star/user/permission', {
            templateUrl: './pages/user/permission_list.html',
            controller: 'permissionListController'
        })
        .when('/star/user/permission_config/:id', {
            templateUrl: './pages/user/permission_config.html',
            controller: 'permissionConfigController'
        })
        .when('/star/user/permission_config/', {
            templateUrl: './pages/user/permission_config.html',
            controller: 'permissionConfigController'
        })
        .when('/star/user/permission_role/:label', {
            templateUrl: './pages/user/permission_role.html',
            controller: 'permissionRoleController'
        })
        .when('/star/user/role', {
            templateUrl: './pages/user/role_list.html',
            controller: 'roleListController'
        })
        .when('/star/user/role_config/:tag/:id', {
            templateUrl: './pages/user/role_config.html',
            controller: 'roleConfigController'
        })
//        .when('/star/user/role_config/', {
//            templateUrl: './pages/user/role_config.html',
//            controller: 'roleConfigController'
//        })
        .when('/star/user/user_policy', {
            templateUrl: './pages/user/user_policy.html',
            controller: 'userPolicyController'
        })
        .when('/star/user/user_role', {
            templateUrl: './pages/user/user_role.html',
            controller: 'userRoleController'
        })
        .when('/star/user/user_capi', {
            templateUrl: './pages/user/user_capi.html',
            controller: 'userCapiController'
        })

        .otherwise({
            redirectTo: '/admin'
        });
}]);

//权限校验
app.run(['$rootScope', '$location', 'userPermissionCheckService', function ($rootScope, $location, userPermissionCheckService) {

    /* 监听路由的状态变化 */
    $rootScope.$on('$routeChangeStart', function (event, msg) {

        console.log('routeChangeStart start');
        var permissionUrl = $location.$$absUrl.split($location.$$host + ':' + $location.$$port)[1]
        if ($location.$$port == 80) {
            permissionUrl = $location.$$absUrl.split($location.$$host)[1]
        }
        if (permissionUrl == '/star/index.html#/star/no_permission') {
            return
        }

        var param = {};
        param.permissionUrl = permissionUrl
        var hasPermission = true
        var procFn = function (response) {
            if (response.data == null || typeof (response.data) == 'undefined') {
                return
            }
            hasPermission = response.data
            if (hasPermission) {
                console.log(permissionUrl + ' pass')
                return
            } else {
                console.log(permissionUrl + ' not pass')
                window.location.href = "/star/index.html#/star/no_permission";
            }
        };
        var errorFn = function (result) {
            console.log('login error: ' + result);
            console.error('permission validate error');
        };
        userPermissionCheckService.permissionValidate(param, procFn, errorFn);
        console.log('routeChangeStart end');
    });

    $rootScope.$on('$routeChangeSuccess', function (evt, current, previous) {
        let permissionUrl = $location.$$absUrl.split($location.$$host + ':' + $location.$$port)
        console.log('route have already changed ：' + permissionUrl);
        if(typeof($GLOBAL_USER)!='undefined') {
            watermark({ watermark_txt: $GLOBAL_USER });
        }
    });

}])

/* Services */
app.service('userPermissionCheckService', ['ajaxService', function (ajaxService) {

    this.permissionValidate = function (params, successFunction, errorFunction) {
        $.ajax({
            url: "/star/api/basic-service/v1/user_permission/validate.do",//请求路径
            async: false,
            data: JSON.stringify(params),
            type: "POST",//GET
            contentType: 'application/json',
            dataType: "JSON",//需要返回JSON对象(如果Ajax返回的是手动拼接的JSON字符串,需要Key,Value都有引号)
            success: function (response, status, headers, config) {
                if ((response.code == '00000001' || response.code == '-100') && response.data != null && response.data.redirectUrl != null) {
                    window.location = response.data.redirectUrl;
                } else {
                    successFunction(response, status);
                }
            },
            error: function (response) {
                if (response.IsAuthenicated == false) { window.location = "/index.html"; }
                errorFunction(response);
            }
        })

    };

}]);


var user_cookie_tag = "ac_key";
/* Controllers */
app.controller('index', ['$scope', '$location', '$rootScope', '$routeParams', 'indexService', function ($scope, $location, $rootScope, $routeParams, indexService) {
    var vm = $scope.vm = {};
    vm.p = {};
    vm.result = {};

    var errorFn = function (result) {
        alert(result);
    };
    $scope.pingDetail = function () {
        var vm = $scope.vm;
        vm.result.ms = "...";
        var params = {};
        var procFn = function (response) {
            vm.result.ms = response.ms;
            var data = response.data;
            if (data == null) return;
            $GLOBAL_USER = data[0].userName;

            watermark({ watermark_txt: $GLOBAL_USER });
        };
        indexService.pingDetail(params, procFn, errorFn);
    };
    $scope.initializeController = function () {
        vm.result.ms = '';
        $scope.pingDetail();
    };
    $scope.initializeController();
}]);


/* Services */
app.service('indexService', ['ajaxService', function (ajaxService) {
    this.list = function (params, successFunction, errorFunction) {
        ajaxService.AjaxGetWithData(params, "./api/v1/bibcp/xxx/list", successFunction, errorFunction);
    };
    this.pingDetail = function (params, successFunction, errorFunction) {
        ajaxService.AjaxPost(params, "/star/api/basic-service/v1/aaa/pingDetail.do", successFunction, errorFunction);
    };
}]);

function formatColor(value) {
    var color = colorByVal(value);
    return ['<font color="',color,'">',value,'</font>'].join('');
}
function formatColorCtx(value,color) {
    return ['<font color="',color,'">',value,'</font>'].join('');
}


function serialFormatter(value, row, index) {
    return index+1;
}

app.filter('contentFmt1', function () {
    return function (input) { // input是我们传入的字符串
        var strs = input.split(",");
        return (strs.length > 1) ? strs[0] : input;
    }
});
app.filter('contentFmt2', function () {
    return function (input) { // input是我们传入的字符串
        var strs = input.split(",");
        return (strs.length > 1) ? strs[1] : input;
    }
});


function crudActionFmt(value, row, index) {
    if (value == null) return "-";
    switch (value) {
        //case 0:
        //    return "新建";
        //    break;
        //case 1:
        //    return "修改";
        //    break;
        case 0:
        case 1:
            return "有效";
            break;
        case 2:
            //return "删除";
            return "无效";
            break;
        case 3:
            return "停用";
            break;
        case 4:
            return "提交审批";
        case 5:
            return "审批通过";
            break;
        case 6:
            return "已运行";
        case 7:
            return "已停止";
        default:
            break;
    }
    return value;
}

function strFormatter(value, row, index) {
    if (value == null) return null;
    return value + "";
}


function orderSubTypeFormatter(value, row, index) {
    if (value == null) return null;
    var ret = '';
    if (value == 0) {
        ret = '堂食';//formatColorCtx('堂食','blue');
    } else if (value == 20) {
        ret = '外卖';//formatColorCtx('外卖','green');
    } else if (value == 21) {
        ret = '自提';//formatColorCtx('自提','yellow');
    } else {
        ret = formatColorCtx('未知:' + value, 'red');
    }
    return ret;
}


function reasonFormatter(value, row, index) {
    if (value == null) return null;
    return formatColorCtx(value, 'red');
}



app.filter('checkReasonIDFormatter', function () {
    return function (value) { // value是我们传入的字符串
        return checkReasonIDFormatter(value, null, null);
    }
});
app.filter('hllDtFormatter', function () {
    return function (value) { // value是我们传入的字符串
        return hll2StdTime(value);
    }
});


app.filter("countNameFmt", function() {
    return function(input) { // input是我们传入的字符串
        if(input==null) return null;
        return quataLineName(input);
    }
});
app.filter("countZhuNameFmt", function() {
    return function(input) { // input是我们传入的字符串
        if(input==null) return null;
        return quataZhuName(input);
    }
});
app.filter("linkFmt", function() {
    return function(input) { // input是我们传入的字符串
        if(input==null) return null;
        var keys = input.rowkey.split("^");
        var resonId = keys[keys.length-1];
        return resonId
    }
});

app.filter("dateFmt", function() {
    return function(input) { // input是我们传入的字符串
        if(input==null) return null;
        var length = input.cntList.length;
        var date = input.cntList[length-1][0];
        return date
    }
});

app.filter("bigNumFmt", function() {
    return function(input) { // input是我们传入的字符串
        return bigNumFmt(input)
    }
});

// 异常ID可视化
function checkReasonIDFormatter(value, row, index) {
    if (value == null) return null;
    return [value, '-', reasonName(value)].join('');
}


function contextFormatter(value, row, index) {
    if (value == null) return null;
    var ret = '';
    var len = value.length;
    var step = 80;
    for (var i = 0; i < len; i += step) {
        ret += value.substr(i, step);
        ret += "<br/>"
    }
    return ret;
}

function orderKeyFormatter(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="#/profiling/', row.groupID, '/', row.shopID, '/', value, '" target="_blank">', value, '</a>'].join('');
}

function licenseCheckFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="#/star/license/license_check/', value, '" target="_blank">', value, '</a>'].join('');
}

function orderIDFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="#/star/order/mall_order_detail/', value, '" target="_blank">', value, '</a>'].join('');
}

function queryLicenseFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="#/star/order/mall_order_detail/', value, '" target="_blank">', "开户进度" , '</a>'].join('');
}

function merchantDetailFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="#/star/merchant/merchant_detail/', value, '" target="_blank">', "开户详情" , '</a>'].join('');
}

function continueRegisterFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return ['<a href="" ng-click="continueRegister(', value, ')">', "失败修复" , '</a>'].join('');
}


function moneyFixedFmt(value, row, index) {
    if (value == null) return null;
    return value.toFixed(2);
}




function getTsBefore(gap){
    if(gap==null || gap==0) gap=0;
    var today=new Date();
    var before=new Date();
    before.setTime(today.getTime()-1000*gap);
    var strYear=before.getFullYear();
    var strDay=before.getDate();
    if(strDay<10) {
        strDay = "0"+strDay;
    }
    var strMonth=before.getMonth()+1;
    if(strMonth<10) {
        strMonth="0"+strMonth;
    }
    var strHour=before.getHours();
    if(strHour<10) {
        strHour="0"+strHour;
    }
    var strMin=before.getMinutes();
    if(strMin<10) {
        strMin="0"+strMin;
    }
    var strSec=before.getSeconds();
    if(strSec<10) {
        strSec="0"+strSec;
    }
    return (""+strYear+strMonth+strDay+strHour+strMin+strSec);
}


function getHMBefore(gap) {
    if (gap == null || gap == 0) gap = 0;
    var today = new Date();
    var before = new Date();
    before.setTime(today.getTime() - 1000 * 60 * gap);
    var strYear = before.getFullYear();
    var strDay = before.getDate();
    if (strDay < 10) {
        strDay = "0" + strDay;
    }
    var strMonth = before.getMonth() + 1;
    if (strMonth < 10) {
        strMonth = "0" + strMonth;
    }
    var strHour = before.getHours();
    if (strHour < 10) {
        strHour = "0" + strHour;
    }
    var strMin = before.getMinutes();
    if (strMin < 10) {
        strMin = "0" + strMin;
    }
    return ("" + strYear + strMonth + strDay + strHour + strMin);
}

function getHBefore(gap) {
    if (gap == null || gap == 0) gap = 0;
    var today = new Date();
    var before = new Date();
    before.setTime(today.getTime() - 1000 * 60 * 60 * gap);
    var strYear = before.getFullYear();
    var strDay = before.getDate();
    if (strDay < 10) {
        strDay = "0" + strDay;
    }
    var strMonth = before.getMonth() + 1;
    if (strMonth < 10) {
        strMonth = "0" + strMonth;
    }
    var strHour = before.getHours();
    if (strHour < 10) {
        strHour = "0" + strHour;
    }
    return ("" + strYear + strMonth + strDay + strHour);
}

function getHMDefault(gap) {
    if (gap == null || gap == 0) gap = 0;
    var today = new Date();
    var before = new Date();
    before.setTime(today.getTime() - 1000 * 60 * 60 * gap);
    var strYear = before.getFullYear();
    var strDay = before.getDate();
    if (strDay < 10) {
        strDay = "0" + strDay;
    }
    var strMonth = before.getMonth() + 1;
    if (strMonth < 10) {
        strMonth = "0" + strMonth;
    }
    return ("" + strYear + strMonth + strDay + "0000");
}

//长字符串表格截取显示
function longContentFmt(value, row, index) {
    if (value.length > 20) {
        // $("#message-text").val(value);
        return value.substring(0, 20) + "..." + "<a data-toggle=\"modal\" data-target=\"#exampleModal\" onclick=\"showLongContent(" + index + ")\" href=\"javascript::void(0)\">[详情]</a>";
    } else {
        return "<div style=\"font-family:'微软雅黑'\">" + value + "</div>";
    }
}

//使用弹框显示所有内容
function showLongContent(index) {
    var element = angular.element($("#message-text"));
    var scope = element.scope();
    scope.$apply(function () {
        scope.index = index;
    });
}

function delete_confirm() {
    return confirm("删除是不可恢复的，你确认要删除吗？");
}

function numberFmt(value, row, index) {
    if (!value) return '';
    return value.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
}

function add0(m) {
    return m < 10 ? '0' + m : m
}

function dateFormat(value, row, index) {
//shijianchuo是整数，否则要parseInt转换
    var time = new Date(value);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
}

function hllCurrentTime() {
//shijianchuo是整数，否则要parseInt转换
    var time = new Date();
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + add0(m) + add0(d) + add0(h) + add0(mm) + add0(s);
}

//自定义指令实现ng-repeat完成后执行repeatFinish方法
app.directive('repeatFinish',function(){
    return {
        link: function(scope,element,attr){
            console.log(scope.$index);
            if(scope.$last == true){
                console.log('ng-repeat over, will draw chart.');
                scope.$eval( attr.repeatFinish )
            }
        }
    }
});
// hll时间转化为std时间
function hll2StdTime(v) {
    if(v==null) return null;
    v+="";// 将对象转为字符串
    if(v.length==14) {// 20181112155301
        return [v.substr(0,4),'-', v.substr(4,2),'-', v.substr(6,2),' ', v.substr(8,2),':', v.substr(10,2),':', v.substr(12,2)].join('');
    }else if(v.length==12) {// 201811121553
        return [v.substr(0,4),'-', v.substr(4,2),'-', v.substr(6,2),' ', v.substr(8,2),':', v.substr(10,2)].join('');
    }else if(v.length==8) {// 20181112
        return [v.substr(0,4),'-', v.substr(4,2),'-', v.substr(6,2)].join('');
    }
}
function hll2StdTimeFmt(value, row, index) {
    // var sourcesize = {data:value};
    return hll2StdTime(value);
}
function objFmt(value, row, index) {
    return JSON.stringify(value);
}


function statusFormatter(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
            return "未使用";
        case 1:
            return "已使用";
        default:
            return "-";
    }
}

function productDetailFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    var arr = [];
    var items = value.split(';');
    for(var i=0;i<items.length; ++i) {
        var it = items[i];
        var vals = it.split(',');
        //var str = ['[',vals[0],']',vals[3],':',vals[2]].join('');
        var str = [vals[3],':',vals[2]].join('');
        arr.push(str);
    }
    return arr.join('<br/>');
}



function subBillStatusFormatter(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
        case 1:
            return "待接单";
        case 2:
            return "待发货";
        case 3:
            return "已收货";
        case 4:
            return "待结算";
        case 5:
            return "已完成";
        case 6:
            return "已取消";
        case 7:
            return "拒收";
        default:
            return "-";
    }
}

function payTypeFormatter(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
        case 1:
            return "货到付款";
        case 2:
            return "账期支付";
        case 3:
            return "线上支付";
        default:
            return "-";
    }
}

function isTestFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    var typeName = '';
    switch (value) {
        case 0:
            typeName = "正常";
            break;
        case 1:
            typeName = "<font color='red'>测试</font>";
            break;
        default:
            typeName = "-";
            break;
    }
    return typeName;
    //return [value,'-',typeName].join('')
}

function productDetailListJsonFmt(value, row, index) {
    if (value == null || value=='null') {
        return "-";
    }
    var rows = [];
    var items = JSON.parse(value);
    for(var i=0;i<items.length; ++i) {
        var data = items[i];
        rows.push(['产品名称：',data['productName'],", 出库数量：",data['productNumber']].join(''));
    }
    return rows.join('<br/>')
}


function reasonTypeFormatter(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
    return [value, '<a href="http://help.hualala.com/pages/viewpage.action?pageId=3146289" target="_blank">帮助</a>'].join('');
}

//function transOrderID2LicenseFmt(value, row, index) {// /profiling/:groupID/:shopID/:saasOrderID
//    return ['<a href="#/star/license/license_list/', value, '" target="_blank">', value , '</a>'].join('');
//}


function deliverOptFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    return [
        '<a href="#/star/order/tfz_order_deliver_add/', value, '/', row.transOrderID, '" target="_blank">', "<u>编辑查看</u>" , '</a>',
        '<a href="#/star/order/tfz_order_deliver_review/', value, '/', row.transOrderID, '" target="_blank">', " <u>申请提交</u>" , '</a>'
    ].join('');
}

function productIDFmt(value, row, index) {
    return ['<a href="#/star/product/product_add/', value, '" target="_blank"> ', "编辑", '</a>'].join('');
}
function userIDFmt(value, row, index) {
    return ['<a href="#/star/user/user_add/', value, '" target="_blank"> ', "编辑", '</a>'].join('');
}


var datetimePicker = function(pickerId,inputId) {
    $(function() {
        //初始化日期控件
        $('#'+pickerId).datetimepicker({
            format : "yyyy-mm-dd",
            weekStart : 1,
            todayBtn : 1,
            autoclose : 1,
            todayHighlight : 1,
            startView : 2,
            forceParse : 0,
            startDate : "2015-01-01",
            minView : 2,
            showMeridian : 1,
            language : "zh-CN"
        });
        //初始化日期控件的输入框
        $('#'+inputId).val(getDateStr(-1));
    });
};

Date.prototype.add = function (part, value) {
    value *= 1;
    if (isNaN(value)) {
        value = 0;
    }
    switch (part) {
        case "y":
            this.setFullYear(this.getFullYear() + value);
            break;
        case "m":
            this.setMonth(this.getMonth() + value);
            break;
        case "d":
            this.setDate(this.getDate() + value);
            break;
        case "h":
            this.setHours(this.getHours() + value);
            break;
        case "n":
            this.setMinutes(this.getMinutes() + value);
            break;
        case "s":
            this.setSeconds(this.getSeconds() + value);
            break;
        default:

    }
};

Date.prototype.format = function(format) {
    var o = {
        "M+": this.getMonth() + 1,
        // month
        "d+": this.getDate(),
        // day
        "h+": this.getHours(),
        // hour
        "m+": this.getMinutes(),
        // minute
        "s+": this.getSeconds(),
        // second
        "q+": Math.floor((this.getMonth() + 3) / 3),
        // quarter
        "S": this.getMilliseconds()
        // millisecond
    };
    if (/(y+)/.test(format) || /(Y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
};


function getNowFormatDate(diff){
    var day = new Date();
    day.setDate(day.getDate() + diff);
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var CurrentDate = "";
    Year= day.getFullYear();//支持IE和火狐浏览器.
    Month= day.getMonth()+1;
    Day = day.getDate();
    CurrentDate += Year;
    if (Month >= 10 ){
        CurrentDate += Month;
    }
    else{
        CurrentDate += "0" + Month;
    }
    if (Day >= 10 ){
        CurrentDate += Day ;
    }
    else{
        CurrentDate += "0" + Day ;
    }
    return CurrentDate;
}


function isTestUserFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
            return "正式";
        case 1:
            return "测试";
        default:
            return "-";
    }
}

function userStatusFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
            return "离职";
        case 1:
            return "在岗";
        default:
            return "-";
    }
}
function rowActionFmt(value, row, index) {
    if (value == null) {
        return "-";
    }
    switch (value) {
        case 0:
            return "新建";
        case 1:
            return "修改";
        case 2:
            return "删除";
        default:
            return "-";
    }
}

function longContentCutFmt(value, row, index) {
    if (value.length > 30) {
        // $("#message-text").val(value);
        return value.substring(0, 30) + "...";
    } else {
        return value;
    }
}


var bizTran = function(area) {
    var biz = '';
    switch(area) {
        case 'HRG指标':
            biz = 'zp';
            break;
        case '赶集指标':
            biz ='ganji';
            break;
        case '58指标':
            biz = '58';
            break;
        case '英才指标':
            biz = 'chinahr';
            break;
        default:
            break;
    }
    return biz;
};

